<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wechat_user', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('ID');
            $table->string('unionid', 30)->default('')->comment('只有在用户将公众号绑定到微信开放平台帐号后，才会出现该字段');
            $table->string('openid', 255)->default('')->comment('用户的标识，对当前公众号唯一')->unique();
            $table->string('session_key', 255)->default('');
            $table->string('nickname', 64)->default('')->comment('用户的昵称');
            $table->string('headimgurl', 256)->default('')->comment('用户头像');
            $table->unsignedTinyInteger('sex')->default(0)->comment('用户的性别，值为1时是男性，值为2时是女性，值为0时是未知');
            $table->string('city', 64)->default('')->comment('用户所在城市');
            $table->string('language', 64)->default('')->comment('用户的语言，简体中文为zh_CN');
            $table->string('province', 64)->default('')->comment('用户所在省份');
            $table->string('country', 64)->default('')->comment('用户所在国家');
            $table->integer('deleted_at')->nullable()->comment('删除时间');
            $table->integer('created_at')->nullable()->comment('创建时间');
            $table->integer('updated_at')->nullable()->comment('修改时间');

        });

        DB::statement('alter table'. ' ' .config('database.connections.mysql.prefix', '').'approval_logs comment "微信用户表"');

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wechat_user');
    }
};
